package ua.at.tsvetkov.samizdat.adapters;

import ua.at.tsvetkov.application.AppConfig;
import ua.at.tsvetkov.samizdat.Key;
import ua.at.tsvetkov.samizdat.R;
import ua.at.tsvetkov.samizdat.data.BookColor;
import ua.at.tsvetkov.util.Log;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AdtBookTextSize extends BaseAdapter {

	private LayoutInflater	mInflater;
	private int					count			= 11;
	private float				startSize	= 8;
	private float				step			= 2;
	private BookColor			bookColor;

	public AdtBookTextSize(Activity context) {
		this.mInflater = LayoutInflater.from(context);
		this.bookColor = BookColor.colors[AppConfig.getInt(Key.BOOK_COLORS_SET, 0)];
		Log.d(bookColor.toString());
	}

	@Override
	public int getCount() {
		return count;
	}

	@Override
	public Object getItem(int position) {
		return startSize + position * step;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = mInflater.inflate(R.layout.adt_book_color, null);
		TextView holder = (TextView) convertView.findViewById(R.id.AdtBookColorText);
		convertView.setBackgroundResource(bookColor.background);
		float size = startSize + position * step;
		holder.setText("Текст " + size);
		holder.setTextSize(size);
		holder.setTextColor(bookColor.textColor);
		return convertView;
	}

}
